package com.example.demo2.service.toic;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

@Service
@RabbitListener(queues = {"ttlweixin_direct"})
public class TTLTest {
    @RabbitHandler
    public void recever(String message1, Message message, Channel channel) throws IOException {
        System.out.println("email_toic接收到队列信息=============》"+message);
        System.out.println(new String(message.getBody(), StandardCharsets.UTF_8));
        Long tag=message.getMessageProperties().getDeliveryTag();
        channel.basicAck(tag,false);
    }
}
